package com.samoiloff.ui.btns.bright {
	import Array;
	import caurina.transitions.Tweener;

	import int;
	import com.samoiloff.ui.btns.bright.BrightBtnController;

	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;

	/**
	 * @author Damirr
	 */
	public class Bright2StateBtnController extends BrightBtnController {
		
		private var _state:int;
		
		public function Bright2StateBtnController(mc: MovieClip) {
			super(mc);
			state = 1;
		}
		
		override protected function onClick(e: MouseEvent): void {
			if (_state == 1) {
				state = 2;
			} else {
				state = 1;
			}
			super.onClick(e);
		}
		
		override protected function onMouseOver(e:MouseEvent): void {
			//Tweener.addTween(_mc, {time:.5, transition:"easeOutCubic", _brightness:.3});
			var mtx: Array = [2, 0, 0, 0, -63.5, 0, 2, 0, 0, -63.5, 0, 0, 2, 0, -63.5, 0, 0, 0, 1, 0];
			Tweener.addTween(_mc, {_ColorMatrix_matrix:mtx, time:0.5 });
			dispatchEvent(e);
		}

		override protected function onMouseOut(e:MouseEvent): void {
			//Tweener.addTween(_mc, {time:.5, transition:"easeOutCubic", _brightness:0});
			var mtx: Array = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
			Tweener.addTween(_mc, { _ColorMatrix_matrix:mtx, time:0.5 });
			dispatchEvent(e);
		}
		
		public function get state(): int {
			return _state;
		}
		
		public function set state(state: int): void {
			_state = state;
			_mc.gotoAndStop(_state);
			dispatchEvent(new Event(Event.CHANGE));
		}
	}
}
